<%@ page contentType="text/html;charset=utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
 	 <link href="css/login.css" type="text/css" rel="stylesheet">
 	 <script src="js/jquery-3.1.0.min.js"></script>
 	 <script type="text/javascript">
	     $(document).ready(function(){ 
	    	 $("#span01").hide();
	      //获取验证码，点击刷新验证码
	    	$("#code_img").attr("src","verification.action?rmd="+new Date().getTime()).click(function(){
		  			$("#code_img").attr("src","verification.action?rmd="+new Date().getTime());
		  		});
		 //判断是否为空	
		 	$("#login").click(function(){
		 	    	 var index=0;
		             $(".text").each(function(){
		                 if($(this).val()==""){
		                	 index++;
		                     alert($(this).attr("placeholder")+"不能为空！");
		                    return false;
		                 }
		             });
		                if(index==0){
		                	var data=$("#verification").val();
		                	$.ajax({
		                		type:"post",
		                		url:"sureVerification.action",
		                		data:{verification:data},
		                		success:function(msg){
		                			if(msg=="success"){
		                				$("form").submit();
		                			}else{
		                				$("#span01").show();
		                			}
		                		}
		                	});
		                	
		                }
	         });
		 	$("#verification").click(function(){
		 		$("#span01").hide();
		 	});
	     });
		
 	 </script>
 	
</head>

	<body>
		<div id="d01"><img id="i01" src="img/hwdg01.jpg"/></div>
        <div id="d02">
            <form action="login.action" method="post">
                <input class="text" type="text" name="userId"  value="${inputUserId}"placeholder="用户名" style="width: 200px;height: 25px;"/><br/><br/><br/>
                <input class="text" type="password" name="password" value="${inputPassword}" placeholder="密码" style="width: 200px;height: 25px;"/><br/>
                <span style="color:red;">${userError}</span><br/><br/>
                <input id="verification" class="text" type="text" name="verification" placeholder="验证码" style="width: 90px;height: 23px;"><img id="code_img" style="position:relative;top:8px;height:25px"/><br/>
                <span style="color:red;" id="span01">验证码不正确</span><br/><br/>
                <a href="register.jsp">注册>></a><a href="resetPassword.jsp" style="float: right;">忘记密码？</a><br/><br/>
                <input id="login" type="button" value="登录" style="width: 200px;height: 25px;"/>
            </form>

        </div>
	</body>
</html>